<%@page import="java.util.Properties"%>
<%@page import="br.net.woodstock.tickettoride.client.beans.PropertiesTicketConverter"%>
<%@page import="br.net.woodstock.tickettoride.client.beans.DefaultTicketHash"%>
<%@page import="br.net.woodstock.tickettoride.client.TicketSession"%>
<%@page import="br.net.woodstock.tickettoride.client.TicketData"%>
<%@page import="br.net.woodstock.tickettoride.client.TicketHash"%>
<%@page import="br.net.woodstock.tickettoride.client.TicketService"%>
<%@page import="br.net.woodstock.tickettoride.client.jdk6.TicketClient"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="ISO-8859-1"%>
<%
	String name = null;
	String email = null;
	String password = null;
	TicketData data = null;
	if(request.getParameter("hash") != null) {
		TicketClient client = TicketClient.getInstance();
		TicketService service = client.getService();
		TicketSession ticketSession = service.getSession();
		TicketHash hash = new DefaultTicketHash(request.getParameter("hash"));
		data = ticketSession.getData(hash);
		PropertiesTicketConverter converter = new PropertiesTicketConverter();
		Properties properties = converter.fromBytes(data.getBytes());
		name = properties.getProperty("name");
		email = properties.getProperty("email");
		password = properties.getProperty("password");
	}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Ticket To Ride - Sample App</title>
</head>
<body>
	Hash<br />
	Name: <input type="text" name="name" value="<%= name %>" /><br />
	E-mail: <input type="text" name="email" value="<%= email %>" /><br />
	Password: <input type="text" name="email" value="<%= password %>" /><br />
	<% if(data != null) { %>
		Application: <%= data.getApplication() %><br />
		Data: <%= data.getDate() %><br />
		expires: <%= data.getExpires() %><br />
	<% } %>
	<br />
	Request Parameter<br />
	Name: <input type="text" name="name" value="<%= request.getParameter("name") %>" /><br />
	E-mail: <input type="text" name="email" value="<%= request.getParameter("email") %>" /><br />
	Password: <input type="text" name="email" value="<%= request.getParameter("password") %>" /><br />
</body>
</html>